package cn.wolfcode.trip.api.controller;

import cn.wolfcode.trip.base.domain.NewsComment;
import cn.wolfcode.trip.base.service.INewsCommentService;
import cn.wolfcode.trip.base.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/newsComments")
public class NewsCommentController {

    @Autowired
    private INewsCommentService newsCommentService;

    /**
     * 保存攻略评论的点评数据
     * @param newsComment
     * @return
     */
    @PostMapping
    public JsonResult save(NewsComment newsComment) {
        JsonResult result = new JsonResult();
        try {
            newsCommentService.saveOrUpdate(newsComment);
        } catch (Exception e) {
            e.printStackTrace();
            result.mark(e.getMessage());
        }
        return result;
    }
    @GetMapping("{NewsCommentId}")
    public Integer queryCountByNewsCommentId(@PathVariable Long NewsCommentId) {

        return newsCommentService.queryCountByNewsCommentId(NewsCommentId);
    }


}
